package com.mindmax.wordmemory.service.impl;

import com.mindmax.wordmemory.domain.VocabularyBank;
import com.mindmax.wordmemory.mapper.VocabularyBankMapper;
import com.mindmax.wordmemory.service.IVocabularyBankService;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 单词库Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-03
 */

@DataSource(value = DataSourceType.WORD_MEMORY)
@Service
public class VocabularyBankServiceImpl implements IVocabularyBankService
{
    @Autowired
    private VocabularyBankMapper vocabularyBankMapper;

    /**
     * 查询单词库
     *
     * @param id 单词库主键
     * @return 单词库
     */
    @Override
    public VocabularyBank selectVocabularyBankById(Long id)
    {
        return vocabularyBankMapper.selectVocabularyBankById(id);
    }

    /**
     * 查询单词库列表
     *
     * @param vocabularyBank 单词库
     * @return 单词库
     */
    @Override
    public List<VocabularyBank> selectVocabularyBankList(VocabularyBank vocabularyBank)
    {
        return vocabularyBankMapper.selectVocabularyBankList(vocabularyBank);
    }

    /**
     * 新增单词库
     *
     * @param vocabularyBank 单词库
     * @return 结果
     */
    @Override
    public int insertVocabularyBank(VocabularyBank vocabularyBank)
    {
        vocabularyBank.setCreateTime(DateUtils.getNowDate());
        return vocabularyBankMapper.insertVocabularyBank(vocabularyBank);
    }

    /**
     * 修改单词库
     *
     * @param vocabularyBank 单词库
     * @return 结果
     */
    @Override
    public int updateVocabularyBank(VocabularyBank vocabularyBank)
    {
        vocabularyBank.setUpdateTime(DateUtils.getNowDate());
        return vocabularyBankMapper.updateVocabularyBank(vocabularyBank);
    }

    /**
     * 批量删除单词库
     *
     * @param ids 需要删除的单词库主键
     * @return 结果
     */
    @Override
    public int deleteVocabularyBankByIds(Long[] ids)
    {
        return vocabularyBankMapper.deleteVocabularyBankByIds(ids);
    }

    /**
     * 删除单词库信息
     *
     * @param id 单词库主键
     * @return 结果
     */
    @Override
    public int deleteVocabularyBankById(Long id)
    {
        return vocabularyBankMapper.deleteVocabularyBankById(id);
    }
}
